<template>
  
  <div class="article-page">
     <!-- @click="$router.push(`/detail?id=${item.id}`)" -->
    <div v-for="item in articles" :key="item.id"
   
    @click="$router.push(`/detail/${item.id}`)"
      class="article-item"
      >
      <div class="head">
        <img :src="item.creatorAvatar" alt="" />
        <div class="con">
          <p class="title">{{item.stem}}</p>
          <p class="other">{{item.creatorName}} | {{item.createAt}}</p>
        </div>
      </div>
      <div class="body">
         {{item.content}}
      </div>
      <div class="foot">点赞 {{item.likeCount}} | 浏览 {{item.views}}</div>
    </div>
  </div>
</template>

<script>
// 请求地址: https://mock.boxuegu.com/mock/3083/articles
// 请求方式: get
import axios from 'axios'
export default {
  name: 'ArticlePage',
  async created(){
    const res=await axios.get('https://mock.boxuegu.com/mock/3083/articles')
    // console.log(res);
    // console.log(res.data.result.rows);
    this.articles=res.data.result.rows
    // console.log(this.article);
  },
  data () {
    return {
     articles:[]
    }
  }
 
}
</script>

<style scoped>
.article-page {
  background: #f5f5f5;
}
.article-item {
  margin-bottom: 10px;
  background: #fff;
  padding: 10px 15px;

}
.article-item .head{
  display: flex;
}
.article-item .head  img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      overflow: hidden;
    }
.article-item .head .con {
      flex: 1;
      overflow: hidden;
      padding-left: 15px;
    }
.article-item .head .con p {
        margin: 0;
        line-height: 1.5;
      }
.article-item .head .con p .title {
          text-overflow: ellipsis;
          overflow: hidden;
          width: 100%;
          white-space: nowrap;
        }

.article-item .head .con p .other {
          font-size: 10px;
          color: #999;
        }
.article-item .body {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-top: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
.article-item .foot {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
  }




</style>



